package main

import (
	"fmt"
	"gitee.com/yunduansing/gocommon/configs"
	"gitee.com/yunduansing/limitsecondkill/application"
	"gitee.com/yunduansing/limitsecondkill/common"
	"gitee.com/yunduansing/limitsecondkill/service"
	"github.com/kataras/iris/v12"
	"strconv"
)

func main()  {
	defer common.CloseDB()
	irisConf:=configs.GetIrisYAMLConfig("./config.yml")
	app:= application.Startup()
	application.RegisterAllRouters(app)
	//初始化库存到redis
	service.SaveStockNumToRedis()

	err:=app.Run(iris.Addr(":"+strconv.Itoa(configs.GetServerPort())),irisConf)
	if err!=nil{
		fmt.Println("Started web service failed.")
	}

	fmt.Println("Started web service successful.")
}
